/**
 * Created by TRwin7SP1 on 2016/8/15.
 */
angular.module('inspinia')
  .controller('validateCtrl',function ($scope,values,fileReader) {





    $scope.print =function () {
      window.print();
    }
    $scope.form = {
      date:"2016-12-31"
    }


    $scope.imageSrc = '';
    var _newDate = new Date();
    $scope.validateForm = {
      patientname:'',
      patientid:'',
      part:'',
      planSystem:'',
      accelerator:'',
      validateType:'',
      dose:'',
      remarks:'',
      motif:'',
      matrixx:'',
      delta:'',
      film:'',
      result:'',
      passRate:'',
      validateDate:_newDate.getFullYear()+"-"+(_newDate.getMonth()+1)+"-"+_newDate.getDay()
    };
    $scope.isPrint =true;

    //设置输入框的maxlength,minlength等信息
    $scope.setting = {
      patientname:{
        maxlength:20,
        minlength:2,
      },
      patientid:{
        maxlength:8,
        minlength:8
      },
      remarks:{
        maxlength:250
      }
    }
    //病种列表
    $scope.parts =values.part;

    //获取加速器列表
    $scope.accelerators = values.accelerators;
  /* console.log(JSON.parse(window.localStorage.getItem('user')).signature);*/
    // $scope.signature = JSON.parse(window.localStorage.getItem('user')).signature;


    $scope.getFile = function () {
      fileReader.readAsDataUrl($scope.file, $scope)
        .then(function (result) {
          $scope.imageSrc = result;
        });
    };
    $scope.openFile = function () {
      angular.element("#myfile").click();
    };
    $scope.imageShow = function () {
      angular.element("#replaceimage").hide();
    };

    $scope.edit = function(){
      $('.valdiateInput').attr('disabled',false);
    }

    $scope.save = function(){
      $('.valdiateInput').attr('disabled',true);
    }

    $scope.save = function(){
      window.localStorage.setItem('validate',JSON.stringify($scope.validateForm));
/*      console.log($scope.validateForm);*/
      // if(!$scope.validateForm.part){}

      // window.location.href = '/#/index/main';

    };

    $scope.print23 = function(){
      /*$('#printArea').jqprint();*/

/*window.print();*/
     /* $scope.isPrint =true;*/
      $("#printArea").jqprint({
        debug: false, //如果是true则可以显示iframe查看效果（iframe默认高和宽都很小，可以再源码中调大），默认是false
        importCSS: true, //true表示引进原来的页面的css，默认是true。（如果是true，先会找$("link[media=print]")，若没有会去找$("link")中的css文件）
        printContainer: true, //表示如果原来选择的对象必须被纳入打印（注意：设置为false可能会打破你的CSS规则）。
        operaSupport: true//表示如果插件也必须支持歌opera浏览器，在这种情况下，它提供了建立一个临时的打印选项卡。默认是true
      });
    };

  })





